/*
导航栏的渐变效果
*/
;(function(document, window, undefined){
    var 
        navbar = document.getElementById("navbar"),
        img = document.getElementById("head-img"),
        change_ = 160,
        didScroll = false;

    window.addEventListener('scroll', function(event){
        if(!didScroll) {
            didScroll = true;
            setTimeout( scrollPage, 50);
        }
    });

    function scrollPage() {
        var sy = scrollY();
        var offset = sy / change_;
        if(offset > 1)
            offset = 1;
        if(offset < 0)
            offset = 0;

        navbar.style.backgroundColor = 'rgba(24,116,205,'+offset+')';

        didScroll = false;
    }

    function scrollY() {
        return window.pageYOffset || document.documentElement.scrollTop;
    }

})(document, window);